package com.etc;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;


import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.LazyOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;


import java.io.File;
import java.io.IOException;

public class offJob {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        Configuration configuration = new Configuration();
        Job job = Job.getInstance(configuration);

        job.setJarByClass(offJob.class);
        job.setMapperClass(offlinemap.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);

        File file = new File("f:\\output");
        if(file.exists()){
            FileUtil.fullyDelete(file);
        }

        LazyOutputFormat.setOutputFormatClass(job, TextOutputFormat.class);

        FileInputFormat.setInputPaths(job,new Path("D:\\QQ下载\\离线项目\\离线项目\\新建文件夹\\input--4天的未清洗的数据\\20170814new"));
        FileOutputFormat.setOutputPath(job,new Path("f:\\output"));
        job.setNumReduceTasks(1);
        job.waitForCompletion(true);
    }
}
